#include "Platforms/sysutil.h"
#include <iostream>
#include <vector>
#include <iomanip>
#include <string>

void 
print_timing(const std::vector<double>& timingdata, 
             int n, 
             int niter,
             const std::string& what) {
  using namespace std;
  cout.setf(ios::floatfield, ios::scientific);
  cout.setf(ios::right, ios::adjustfield);
  cout.precision(6);

  string whoareyou = getUserName(); 
  string whereareyou = getHostName();
  string when = getDateAndTime();
  cout << n << "," << niter << ",\n"
       << timingdata[7] << "," //f77
       << timingdata[6] << "," //c restrict
       << timingdata[5] << "," //vector[i]
       << timingdata[4] << "," //PETE of vector
       << timingdata[3] << "," //vector[i] for 3D TinyVector
       << timingdata[2] << ",\n" //PETE of vector of 3D TinyVector
       << "\'" << when << "\',\n\'" <<what << "\'" << endl;
  cout << n << "," << niter 
       << "\n f77 " << timingdata[7]  //f77
       << "\n c-restrict " << timingdata[6]  //c restrict
       << "\n stl " << timingdata[5]  //vector[i]
       << "\n pete " << timingdata[4]  //PETE of vector
       << "\n stl-pete " << timingdata[3]  //vector[i] for 3D TinyVector
       << "\n pete-pete " << timingdata[2] //PETE of vector of 3D TinyVector
       << endl;
/*
  cout << "<tr>\n"
       << "<td span=\"6\">"
       << n << "," << niter << "," << whoareyou << "," << whereareyou << "," << when<< "</td>\n"
       <<"</tr>" << endl;
  cout << "<tr>\n" 
       << "<td>CPU</td>\n"
       << "<td>" << timingdata[2] << "</td>\n" 
       << "<td>" << timingdata[3] << "</td>\n" 
       << "<td>" << timingdata[4] << "</td>\n" 
       << "<td>" << timingdata[5] << "</td>\n" 
       << "<td>" << timingdata[6] << "</td>\n" 
       << "<td>" << timingdata[7] << "</td>\n" 
       << "</tr>" << endl;
  cout << "<tr>\n" 
       << "<td>AP</td>\n" 
       << "<td>" << timingdata[2]/timingdata[5] << "</td>\n" 
       << "<td>" << timingdata[3]/timingdata[5] << "</td>\n" 
       << "<td>" << timingdata[4]/timingdata[5] << "</td>\n" 
       << "<td>" << timingdata[5]/timingdata[5] << "</td>\n" 
       << "<td> N/A </td>\n" 
       << "<td> N/A </td>\n" 
       << "</tr>" << endl;
  cout << "<tr>\n" 
       << "<td>CP</td>\n" 
       << "<td>" << timingdata[2]/timingdata[6] << "</td>\n" 
       << "<td>" << timingdata[3]/timingdata[6] << "</td>\n" 
       << "<td>" << timingdata[4]/timingdata[6] << "</td>\n" 
       << "<td>" << timingdata[5]/timingdata[6] << "</td>\n" 
       << "<td>" << timingdata[6]/timingdata[6] << "</td>\n" 
       << "<td>" << timingdata[7]/timingdata[6] << "</td>\n" 
       << "</tr>" << endl;
  cout << "<tr>\n" 
       << "<td>FP</td>\n" 
       << "<td>" << timingdata[2]/timingdata[7] << "</td>\n" 
       << "<td>" << timingdata[3]/timingdata[7] << "</td>\n" 
       << "<td>" << timingdata[4]/timingdata[7] << "</td>\n" 
       << "<td>" << timingdata[5]/timingdata[7] << "</td>\n" 
       << "<td>" << timingdata[6]/timingdata[7] << "</td>\n" 
       << "<td>" << timingdata[7]/timingdata[7] << "</td>\n" 
       << "</tr>" << endl;
*/

  /*
  cout << "Vector<TinyVector<3> > Allocation " << setw(10) << timingdata[0] << endl;
  cout << "Vector<TinyVector<3> > Assignment " << setw(10) << timingdata[1] << endl;

  cout << endl << "Averaged over " << niter << endl;
  cout << endl
       << "Operations A = B + 0.13*C + 0.017* D  "
	<< setw(10) << "CPU secs" << setw(10) << "Penalty"
        << " C-penalty" << endl;
  cout << "AbstractionTest0           " 
       << setw(15) << timingdata[2] 
       << setw(15) << timingdata[2]/timingdata[5] 
       << setw(15) << timingdata[2]/timingdata[7]<< endl;

  cout << "AbstractionTest1           "
       << setw(15) << timingdata[3] 
       << setw(15) << timingdata[3]/timingdata[5] 
       << setw(15) << timingdata[3]/timingdata[7]<< endl;

  cout << "AbstractionTest2           " 
       << setw(15) << timingdata[4] 
       << setw(15) << timingdata[4]/timingdata[5] 
       << setw(15) << timingdata[4]/timingdata[7]<< endl;

  cout << "AbstractionTest3           " 
       << setw(15) << timingdata[5] 
       << setw(15) << timingdata[5]/timingdata[5] 
       << setw(15) << timingdata[5]/timingdata[7]<< endl;

  cout << "C inline function restrict " 
       << setw(15) << timingdata[6] 
       << setw(30) << timingdata[6]/timingdata[7]<< endl;
  cout << "fortran subroutine         " 
       << setw(15) << timingdata[7] 
       << setw(30) << timingdata[7]/timingdata[7]<< endl;

  cout << endl;
  */
}
